package com.rally.calculator;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;

public abstract class AbstractOperand implements IOperand, ActionListener {
	JTextField txtInput1;
	JTextField txtInput2;
	JTextField txtResult;	
	
	public AbstractOperand(JTextField textInput1, JTextField textInput2, JTextField result) {
		this.txtInput1 = textInput1;
		this.txtInput2 = textInput2;
		// this is a comment for demo
		this.txtResult = result;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		String txtInput1 = this.txtInput1.getText();
		int input1 = Integer.parseInt(txtInput1);
		String txtInput2 = this.txtInput1.getText();
		int input2 = Integer.parseInt(txtInput2);
		int result = operation(input1, input2);
		txtResult.setText(result+"");
	}	

}
